%%%-------------------------------------------------------------------
%%% @author mirahs(2892727493@qq.com)
%%% @doc
%%%     mnesia 数据相关
%%% @end
%%%-------------------------------------------------------------------
-module(db_mnesia_info).

-export([get/1, set/2]).

-include("common.hrl").
-include("mnesia.hrl").


%%%===================================================================
%%% API functions
%%%===================================================================

get(Key) ->
    case db_mnesia:read(mnesia_info, Key) of
        {ok, [#mnesia_info{value = Val}]} ->
            Val;
        _ ->
            undefined
    end.

set(Key, Val) ->
    case db_mnesia:write(mnesia_info, #mnesia_info{key = Key, value = Val}) of
        {ok, _} ->
            ok;
        {error, Reason} ->
            {error, Reason}
    end.
